
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>ESLint · introduce</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Gj">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-tomorrow.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../index.css">
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="permission.html" />
    
    
    <link rel="prev" href="i18n.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    引导
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="vscode.html">
            
                <a href="vscode.html">
            
                    
                    Vscode
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="jsdoc.html">
            
                <a href="jsdoc.html">
            
                    
                    Jsdoc
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="webpack.html">
            
                <a href="webpack.html">
            
                    
                    Webpack
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="router.html">
            
                <a href="router.html">
            
                    
                    路由和侧边栏
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="env.html">
            
                <a href="env.html">
            
                    
                    环境变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="cors.html">
            
                <a href="cors.html">
            
                    
                    跨域问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="router-lazyload.html">
            
                <a href="router-lazyload.html">
            
                    
                    路由懒加载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="icons.html">
            
                <a href="icons.html">
            
                    
                    图标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="i18n.html">
            
                <a href="i18n.html">
            
                    
                    国际化
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.11" data-path="eslint.html">
            
                <a href="eslint.html">
            
                    
                    ESLint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="permission.html">
            
                <a href="permission.html">
            
                    
                    权限验证
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="style.html">
            
                <a href="style.html">
            
                    
                    样式
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >ESLint</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="eslint">ESLint</h1>
<p>&#x4E0D;&#x7BA1;&#x662F;&#x591A;&#x4EBA;&#x5408;&#x4F5C;&#x8FD8;&#x662F;&#x4E2A;&#x4EBA;&#x9879;&#x76EE;&#xFF0C;&#x4EE3;&#x7801;&#x89C4;&#x8303;&#x90FD;&#x662F;&#x5F88;&#x91CD;&#x8981;&#x7684;&#x3002;&#x8FD9;&#x6837;&#x505A;&#x4E0D;&#x4EC5;&#x53EF;&#x4EE5;&#x5F88;&#x5927;&#x7A0B;&#x5EA6;&#x5730;&#x907F;&#x514D;&#x57FA;&#x672C;&#x8BED;&#x6CD5;&#x9519;&#x8BEF;&#xFF0C;&#x4E5F;&#x4FDD;&#x8BC1;&#x4E86;&#x4EE3;&#x7801;&#x7684;&#x53EF;&#x8BFB;&#x6027;&#x3002;</p>
<h2 id="&#x914D;&#x7F6E;&#x9879;">&#x914D;&#x7F6E;&#x9879;</h2>
<p>&#x6240;&#x6709;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x90FD;&#x5728; <a href="https://github.com/PanJiaChen/vue-element-admin/blob/master/.eslintrc.js" target="_blank">.eslintrc.js</a> &#x4E2D;&#x3002; &#x672C;&#x9879;&#x76EE;&#x57FA;&#x672C;&#x89C4;&#x8303;&#x662F;&#x4F9D;&#x6258;&#x4E8E; vue &#x5B98;&#x65B9;&#x7684; eslint &#x89C4;&#x5219; <a href="https://github.com/vuejs/eslint-config-vue" target="_blank">eslint-config-vue</a> &#x505A;&#x4E86;&#x5C11;&#x8BB8;&#x7684;&#x4FEE;&#x6539;&#x3002;&#x5927;&#x5BB6;&#x53EF;&#x4EE5;&#x6309;&#x7167;&#x81EA;&#x5DF1;&#x7684;&#x9700;&#x6C42;&#x8FDB;&#x884C;&#x5B9A;&#x5236;&#x5316;&#x914D;&#x7F6E;&#x3002;</p>
<p>&#x6BD4;&#x5982;&#xFF1A;&#x6211;&#x4E2A;&#x4EBA;&#x6216;&#x8005;&#x9879;&#x76EE;&#x7EC4;&#x4E60;&#x60EF;&#x4E8E;&#x4F7F;&#x7528;&#x4E24;&#x4E2A;&#x7A7A;&#x683C;&#xFF0C;&#x4F46;&#x4F60;&#x53EF;&#x80FD;&#x89C9;&#x5F97;&#x56DB;&#x4E2A;&#x7A7A;&#x683C;&#x66F4;&#x987A;&#x773C;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x505A;&#x5982;&#x4E0B;&#x4FEE;&#x6539;&#x3002; &#x8FDB;&#x5165;&#x9879;&#x76EE; <code>.eslintrc.js</code> &#x4E2D;&#xFF0C;&#x627E;&#x5230; <code>indent</code>&#xFF0C;&#x7136;&#x540E;&#x4FEE;&#x6539;&#x4E3A; <code>4</code> &#x5373;&#x53EF;&#x3002; &#x8FD8;&#x6709;&#x5404;&#x79CD;&#x5404;&#x6837;&#x7684;&#x914D;&#x7F6E;&#x4FE1;&#x606F;&#xFF0C;&#x8BE6;&#x60C5;&#x89C1; <a href="https://eslint.org/docs/rules/" target="_blank">ESLint &#x6587;&#x6863;</a>&#x3002;</p>
<p>&#x5728; <a href="https://github.com/PanJiaChen/vue-element-admin/releases/tag/v3.8.1" target="_blank">v3.8.1</a>&#x7248;&#x672C;&#x4E4B;&#x540E;&#xFF0C;&#x589E;&#x52A0;&#x4E86;<a href="https://github.com/vuejs/eslint-plugin-vue" target="_blank">eslint-plugin-vue</a>&#x6765;&#x66F4;&#x597D;&#x7684;&#x6821;&#x9A8C; vue &#x76F8;&#x5173;&#x4EE3;&#x7801;&#x3002;</p>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#x4F7F;&#x7528;&#x4E86;&#x6700;&#x4E25;&#x683C;&#x7684;<code>plugin:vue/recommended</code>&#x6765;&#x6821;&#x9A8C;&#x4EE3;&#x7801;&#xFF0C;&#x82E5;&#x4F60;&#x89C9;&#x5F97;&#x592A;&#x4E25;&#x683C;&#x53EF;&#x81EA;&#x884C;&#x4FEE;&#x6539;&#x3002;</p>
<pre class="language-"><code class="lang-js"><span class="token comment">// https://github.com/PanJiaChen/vue-element-admin/blob/master/.eslintrc.js</span>

module<span class="token punctuation">.</span>exports <span class="token operator">=</span> <span class="token punctuation">{</span>
  <span class="token keyword">extends</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&apos;plugin:vue/recommended&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;eslint:recommended&apos;</span><span class="token punctuation">]</span>
  <span class="token comment">//&#x4F60;&#x53EF;&#x4EE5;&#x4FEE;&#x6539;&#x4E3A;  extends: [&apos;plugin:vue/essential&apos;, &apos;eslint:recommended&apos;]</span>
<span class="token punctuation">}</span>
</code></pre>
<h2 id="&#x53D6;&#x6D88;-eslint-&#x6821;&#x9A8C;">&#x53D6;&#x6D88; ESLint &#x6821;&#x9A8C;</h2>
<p>&#x5982;&#x679C;&#x4F60;&#x4E0D;&#x60F3;&#x4F7F;&#x7528; ESLint &#x6821;&#x9A8C;&#xFF08;&#x4E0D;&#x63A8;&#x8350;&#x53D6;&#x6D88;&#xFF09;&#xFF0C;&#x53EA;&#x8981;&#x627E;&#x5230; <a href="https://github.com/PanJiaChen/vue-element-admin/blob/master/vue.config.js" target="_blank">vue.config.js</a> &#x6587;&#x4EF6;&#x3002; &#x8FDB;&#x884C;&#x5982;&#x4E0B;&#x8BBE;&#x7F6E; <code>lintOnSave: false</code> &#x5373;&#x53EF;&#x3002;</p>
<h2 id="vscode-&#x914D;&#x7F6E;-eslint">vscode &#x914D;&#x7F6E; ESLint</h2>
<p>&#x8FD9;&#x6240;&#x8C13;&#x5DE5;&#x6B32;&#x5584;&#x5176;&#x4E8B;&#xFF0C;&#x5FC5;&#x5148;&#x5229;&#x5176;&#x5668;&#xFF0C;&#x4E2A;&#x4EBA;&#x63A8;&#x8350; eslint+vscode &#x6765;&#x5199; vue&#xFF0C;&#x7EDD;&#x5BF9;&#x6709;&#x79CD;&#x98DE;&#x4E00;&#x822C;&#x7684;&#x611F;&#x89C9;&#x3002;&#x6548;&#x679C;&#x5982;&#x56FE;&#xFF1A; <img src="https://panjiachen.gitee.io/gitee-cdn/vue-element-admin-site/e94a76df-6dc0-4c15-9785-28b553a163e9.png" alt="eslintGif.gif"></p>
<p>&#x6BCF;&#x6B21;&#x4FDD;&#x5B58;&#xFF0C;vscode &#x5C31;&#x80FD;&#x6807;&#x7EA2;&#x4E0D;&#x7B26;&#x5408; eslint &#x89C4;&#x5219;&#x7684;&#x5730;&#x65B9;&#xFF0C;&#x540C;&#x65F6;&#x8FD8;&#x4F1A;&#x505A;&#x4E00;&#x4E9B;&#x7B80;&#x5355;&#x7684;&#x81EA;&#x6211;&#x4FEE;&#x6B63;&#x3002;&#x5B89;&#x88C5;&#x6B65;&#x9AA4;&#x5982;&#x4E0B;&#xFF1A;</p>
<p>&#x9996;&#x5148;&#x5B89;&#x88C5; eslint &#x63D2;&#x4EF6; <img src="https://panjiachen.gitee.io/gitee-cdn/vue-element-admin-site/72f126cb-09eb-4b27-b02e-65e79eb76220.png" alt="eslint1.png"></p>
<p>&#x5B89;&#x88C5;&#x5E76;&#x914D;&#x7F6E;&#x5B8C;&#x6210; ESLint &#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x7EE7;&#x7EED;&#x56DE;&#x5230; VSCode &#x8FDB;&#x884C;&#x6269;&#x5C55;&#x8BBE;&#x7F6E;&#xFF0C;&#x4F9D;&#x6B21;&#x70B9;&#x51FB; &#x6587;&#x4EF6; &gt; &#x9996;&#x9009;&#x9879; &gt; &#x8BBE;&#x7F6E; &#x6253;&#x5F00; VSCode &#x914D;&#x7F6E;&#x6587;&#x4EF6;,&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x914D;&#x7F6E;</p>
<pre class="language-"><code class="lang-json"><span class="token punctuation">{</span>
  <span class="token property">&quot;files.autoSave&quot;</span><span class="token operator">:</span> <span class="token string">&quot;off&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;eslint.validate&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span>
    <span class="token string">&quot;javascript&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;javascriptreact&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;vue-html&quot;</span><span class="token punctuation">,</span>
    <span class="token punctuation">{</span>
      <span class="token property">&quot;language&quot;</span><span class="token operator">:</span> <span class="token string">&quot;vue&quot;</span><span class="token punctuation">,</span>
      <span class="token property">&quot;autoFix&quot;</span><span class="token operator">:</span> <span class="token boolean">true</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token property">&quot;eslint.run&quot;</span><span class="token operator">:</span> <span class="token string">&quot;onSave&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;eslint.autoFixOnSave&quot;</span><span class="token operator">:</span> <span class="token boolean">true</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8FD9;&#x6837;&#x6BCF;&#x6B21;&#x4FDD;&#x5B58;&#x7684;&#x65F6;&#x5019;&#x5C31;&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x6839;&#x76EE;&#x5F55;&#x4E0B;.eslintrc.js &#x4F60;&#x914D;&#x7F6E;&#x7684; eslint &#x89C4;&#x5219;&#x6765;&#x68C0;&#x67E5;&#x548C;&#x505A;&#x4E00;&#x4E9B;&#x7B80;&#x5355;&#x7684; fix&#x3002;&#x6BCF;&#x4E2A;&#x4EBA;&#x548C;&#x56E2;&#x961F;&#x90FD;&#x6709;&#x81EA;&#x5DF1;&#x7684;&#x4EE3;&#x7801;&#x89C4;&#x8303;&#xFF0C;&#x7EDF;&#x4E00;&#x5C31;&#x597D;&#x4E86;&#xFF0C;&#x53BB;&#x6253;&#x9020;&#x4E00;&#x4EFD;&#x5C5E;&#x4E8E;&#x81EA;&#x5DF1;&#x7684; eslint &#x89C4;&#x5219;&#x4E0A;&#x4F20;&#x5230; npm &#x5427;&#xFF0C;&#x5982;&#x997F;&#x4E86;&#x4E48;&#x56E2;&#x961F;&#x7684; <a href="https://www.npmjs.com/package/eslint-config-elemefe" target="_blank">config</a>&#xFF0C;vue &#x7684; <a href="https://github.com/vuejs/eslint-config-vue" target="_blank">config</a>&#x3002;</p>
<p><a href="https://github.com/varHarrie/Dawn-Blossoms/issues/10" target="_blank">vscode &#x63D2;&#x4EF6;&#x548C;&#x914D;&#x7F6E;&#x63A8;&#x8350;</a></p>
<h2 id="&#x66F4;&#x591A;&#x914D;&#x7F6E;">&#x66F4;&#x591A;&#x914D;&#x7F6E;</h2>
<p>&#x7531;&#x4E8E;&#x672C;&#x9879;&#x76EE;&#x662F;&#x57FA;&#x4E8E;<code>vue-cli</code>&#x8FDB;&#x884C;&#x6784;&#x5EFA;&#xFF0C;&#x6240;&#x4EE5;&#x66F4;&#x591A;&#x914D;&#x7F6E;&#x53EF;&#x53C2;&#x8003;&#x5B98;&#x65B9;<a href="https://cli.vuejs.org/zh/config/#lintonsave" target="_blank">&#x6587;&#x6863;</a></p>
<h2 id="&#x81EA;&#x52A8;&#x4FEE;&#x590D;">&#x81EA;&#x52A8;&#x4FEE;&#x590D;</h2>
<pre class="language-"><code class="lang-bash"><span class="token function">npm</span> run lint -- --fix
</code></pre>
<p>&#x8FD0;&#x884C;&#x5982;&#x4E0A;&#x547D;&#x4EE4;&#xFF0C;eslint &#x4F1A;&#x81EA;&#x52A8;&#x4FEE;&#x590D;&#x4E00;&#x4E9B;&#x7B80;&#x5355;&#x7684;&#x9519;&#x8BEF;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="i18n.html" class="navigation navigation-prev " aria-label="Previous page: 国际化">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="permission.html" class="navigation navigation-next " aria-label="Next page: 权限验证">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"ESLint","level":"1.11","depth":1,"next":{"title":"权限验证","level":"1.12","depth":1,"path":"src/permission.md","ref":"src/permission.md","articles":[]},"previous":{"title":"国际化","level":"1.10","depth":1,"path":"src/i18n.md","ref":"src/i18n.md","articles":[]},"dir":"ltr"},"config":{"plugins":["expandable-chapters","-lunr","-search","search-pro","-highlight","prism","livereload"],"styles":{"website":"index.css"},"pluginsConfig":{"prism":{"css":["prismjs/themes/prism-tomorrow.css"]},"expandable-chapters":{},"search-pro":{},"livereload":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Gj","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"introduce","language":"zh-hans","gitbook":"3.2.3","description":"项目搭建、规范、使用示例介绍"},"file":{"path":"src/eslint.md","mtime":"2020-07-29T03:17:24.301Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-07-29T07:02:36.580Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

